package io.jft.doll.ui.room.detailFragment

import android.arch.lifecycle.ViewModelProviders
import android.databinding.ViewDataBinding
import android.os.Bundle
import com.g.base.room.entity.UserEntity
import com.g.base.ui.BaseFragment
import io.jft.doll.R
import io.jft.doll.model.viewModel.RoomViewModel

/**
 * Created by G on 2017/12/21 0021.
 */
abstract class RoomBaseFragment<T : ViewDataBinding> : BaseFragment<T>() {
    protected val roomViewModel by lazy { ViewModelProviders.of(activity!!).get(RoomViewModel::class.java) }


    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        baseRootView.background = resources.getDrawable(R.color.colorItemBackground)
    }

    override fun onReload() {
        getData()
    }

    override fun onTokenChange(data: UserEntity?) {
        if (data == null) {
            getData()
        } else {
            showNeedOauth()
        }
    }

    protected abstract fun getData()
}